// 发布订阅
// 添加订阅
export function addSubscription(subsrciptions, cb) {
  subsrciptions.push(cb);
  // 移除订阅
  return function removeSubsrciption() {
    const idx = subsrciptions.indexOf(cb);
    if (idx > -1) {
      subsrciptions.splice(idx, 1);
    }
  }
}
// 发布广播
export function triggerSubscription(subsrciptions, ...args) {
  subsrciptions.forEach(cb => cb(...args));
}